package Lee_code;

import java.util.HashMap;

public class Lee_384 {
    public int firstUniqChar(String s) {
        char[] ch = s.toCharArray();

        HashMap<Character, Integer> freq = new HashMap<>();

        for(char i: ch)
        {
            freq.put(i, freq.getOrDefault(i,0)+1);
        }
        for(int i=0; i<ch.length; i++)
        {
            if( freq.get(ch[i]) ==1)
                return i;
        }
        return -1;
    }

}
